home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / music / cthugha5.zip / CTHU5SRC.ZIP / PATCH.C < prev    next >
C/C++ Source or Header  |  1994-08-19  |  2KB  |  140 lines

  1. #ifdef _MSC_VER
  2.  
  3. #include <dos.h>
  4. #include <stdlib.h>
  5. #include <memory.h>
  6. #include <time.h>
  7.  
  8. #include "patch.h"
  9.  
  10. #if 0
  11. void (__cdecl __interrupt __far * __cdecl getvect(unsigned i))()
  12. {
  13.     return _dos_getvect(i);
  14. }
  15.  
  16. void __cdecl setvect(unsigned i, void (__cdecl __interrupt __far *h)())
  17. {
  18.     _dos_setvect(i,h);
  19. }
  20. #endif
  21.  
  22. unsigned long speed;  /*  used by delay functions */
  23.  
  24. volatile int in; /* used for initialization */
  25.  
  26. unsigned long current;    /* used for consistant timings */
  27. unsigned long total;
  28.  
  29. void delay(unsigned int ms);
  30.  
  31. #ifdef _MSC_VER
  32. static void (_interrupt _far *oldtimr)(void);
  33. #else
  34. static void __interrupt __far (*oldtimr)(void);
  35. #endif
  36.  
  37. void interrupt far timr()
  38. {
  39.     in++;
  40.     (*oldtimr)();
  41. }
  42.  
  43. /* Initialize delay loop, I think this works... :) */
  44.  
  45. void delay_init(void)
  46. {
  47.     oldtimr = _dos_getvect(0x08);
  48.     _dos_setvect(0x08,timr);
  49.  
  50.     current = 0;
  51.     total = 1;
  52.  
  53.     in = -1;
  54.  
  55.     while( in < 0 );
  56.  
  57.     while( (current<total) && (in == 0) ) speed++;
  58.  
  59. //    speed = ( speed * 107 ) / 100;            // Looking back, this makes no sense.
  60.  
  61.     in = 0;
  62.     _dos_setvect(0x08,oldtimr);
  63. }
  64.  
  65. void delay(unsigned ms)
  66. {
  67.     if( !speed )
  68.         delay_init();
  69.  
  70.     current = 0;
  71.  
  72.     total = (speed * ms) / 55;                    // Clock tick = 55 milliseconds
  73.  
  74.     while( (current < total) && (in == 0) ) current++;
  75. }
  76.  
  77.  
  78. /* Following routines are otherwise accounted for or no longer used */
  79.  
  80. #if 0
  81.  
  82. void textattr(int i)
  83. {
  84. // Put a routine to set BIOS colors here
  85. }
  86.  
  87. void pokeb(unsigned int screen,unsigned int offset, char c)
  88. {
  89.     char *disp;
  90.  
  91.     FP_SEG(disp)=screen;
  92.     FP_OFF(disp)=offset;
  93.  
  94.     *disp=c;
  95. }
  96.  
  97. void poke(unsigned int screen,unsigned int offset, int i)
  98. {
  99.     int *disp;
  100.  
  101.  
  102.     FP_SEG(disp)=screen;
  103.     FP_OFF(disp)=offset;
  104.  
  105.     *disp=i;
  106. }
  107.  
  108. char peekb(unsigned int screen,unsigned int offset)
  109. {
  110.     char *disp;
  111.  
  112.     FP_SEG(disp)=screen;
  113.     FP_OFF(disp)=offset;
  114.  
  115.     return *disp;
  116.     return 0;
  117. }
  118.  
  119. int gettext(int x1,int y1,int x2,int y2, char *buff)
  120. {
  121.  
  122. }
  123.  
  124. int puttext(int x1,int y1,int x2,int y2, char *buff)
  125. {
  126.  
  127. }
  128.  
  129. int window(int x1,int y1, int x2, int y2)
  130. {
  131.  
  132. }
  133.  
  134. int clrscr(void)
  135. {
  136.  
  137. }
  138. #endif
  139. #endif
  140.